/*This file is part of ILoveHUSTBoard.

ILoveHUSTBoard is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

ILoveHUSTBoard is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with ILoveHUSTBoard.  If not, see <http://www.gnu.org/licenses/>.*/

function shareTo(site) {
    var sites = {
        'douban': {
            'url': "http://www.douban.com/recommend/?url={{ url }}&title={{ title }}",
            'name': "豆瓣"
        },
        'renren': {
            'url': "http://share.renren.com/share/buttonshare.do?link={{ url }}&title={{ title }}",
            'name': "人人"
        },
        'qzone': {
            'url': "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url={{ url }}&title={{ title }}",
            'name': "QQ空间"
        },
        'tqq': {
            'url': "http://v.t.qq.com/share/share.php?url={{ url }}&title={{ title }}",
            'name': "腾讯微博"
        },
        'kaixin': {
            'url': "http://www.kaixin001.com/~repaste/repaste.php?&rurl={{ url }}&rtitle={{ title }}&rcontent=",
            'name': "开心网"
        },
        'tsina': {
            'url': "http://v.t.sina.com.cn/share/share.php?url={{ url }}&title={{ title }}",
            'name': "新浪微博"
        }
    };
    var url = document.location.href,
        title = document.title;
    var height = 436,
        width = 626;
    var left = (screen.width - width) / 2,
        top = (screen.height - height) / 2;
    var name = "分享到" + sites[site]['name'];
    var to_url = sites[site]['url'].replace("{{ url }}", encodeURIComponent(url)).replace("{{ title }}", encodeURIComponent(title));

    function x() {
        var par = "toolbar=0,status=0,resizable=1,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top;
        window.open(to_url, name, par);
    }
    if (/Firefox/.test(navigator.userAgent)) {
        setTimeout(x, 0);
    } else {
        x();
    }
}